//
//  CategoryItem.m
//  Dresshere
//
//  Created by ZhangPeng on 2018/6/12.
//  Copyright © 2018年 张朋. All rights reserved.
//

#import "CategoryItem.h"

@interface CategoryItem()

@property (strong, nonatomic) UIImageView *iconImgView;
@property (strong, nonatomic) UILabel *titleLabel;

@end

@implementation CategoryItem

- (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title icon:(NSString *)str
{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.cornerRadius = frame.size.height / 2;
        
        self.iconImgView = [[UIImageView alloc] initWithFrame:CGRectMake(8, 5, frame.size.height - 10, frame.size.height - 10)];
        [self.iconImgView dh_setImageURLString:str];
        self.iconImgView.layer.cornerRadius = self.iconImgView.height / 2;
        self.iconImgView.clipsToBounds = YES;
        [self addSubview:self.iconImgView];
        
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.iconImgView.right + 5, 0, frame.size.width - 16 - self.iconImgView.width - 5, frame.size.height)];
        self.titleLabel.text = title;
        self.titleLabel.font = [UIFont systemFontOfSize:14];
        self.titleLabel.textColor = [UIColor colorWithHexString:@"#575757"];
        [self addSubview:self.titleLabel];
    }
    return self;
}

- (void)enlarge{
    [self setBackgroundColor:[UIColor colorWithHexString:@"#5F657B"]];
    self.titleLabel.textColor = [UIColor whiteColor];
}

- (void)narrow{
    [self setBackgroundColor:[UIColor clearColor]];
    self.titleLabel.textColor = [UIColor colorWithHexString:@"#575757"];
}

@end
